﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Web/Master/MasterPage.master" AutoEventWireup="true" CodeFile="Cart.aspx.cs" Inherits="Web.Cart" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    您确定要删除此条订单吗？
                </div>
                <div class="modal-body">
                    <span class="text-primary" id="delete_book_name"></span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <asp:TextBox Style="display: none;" ID="CartId" runat="server"></asp:TextBox>
                    <asp:Button class="btn btn-danger btn-ok" ID="BtnDeleteCart" runat="server" Text="删除" OnClick="BtnDeleteCart_Click" />
                </div>
            </div>
        </div>
    </div>
    <h2>
        <strong style="margin: 2%;">我的购物车</strong>
        <hr class="bg-info">
        <asp:TextBox Style="display: none;" ID="NewNum" runat="server"></asp:TextBox>
        <asp:Button class="btn btn-sm btn-outline-secondary" ID="BtnUpdate" runat="server" Text="更新购物车" Style="display: none;" OnClick="BtnUpdate_Click"/>
        <asp:Button class="btn btn-sm btn-outline-secondary" ID="BtnOrder" runat="server" Text="下单"  Style="display: none;"  OnClick="BtnOrder_Click"/>
    </h2>
    <div id="page_cart" class="card">
        <table class="table table-hover text-center">
            <tbody>
                <%=CartList %>
            </tbody>
        </table>
        <h1 class="text-center text-info">
            <asp:Label ID="EmptyInfo" runat="server" Text=""></asp:Label></h1>
        <br />
    </div>

    <script>
        $(function () {
                // 数量减按钮
                $(".btn_reduce").click(function () {
                    var number = $(this).parent("span").next().children();
                    var id = $(this).parent("span").next().next().val();
                    //alert(id);
                    //alert(number.val());
                    if (number.val() <= 1) {
                        $(this).disabled = ture;
                    } else {
                        number.val(number.val() - 1);
                    }
                    $(<%=NewNum.ClientID%>).val(number.val());
                    $(<%=CartId.ClientID%>).val(id);
                    $(<%=BtnUpdate.ClientID%>).click();
                });


                // 数量加按钮
            $(".btn_add").click(function () {
                var number = $(this).parent("span").prev().prev().children();
                var id = $(this).parent("span").prev().val();
                //alert(id);
                //alert(number.val());
                    if (number.val() >= 10) {
                        $(this).disabled = ture;
                    } else {
                        number.val(parseInt(number.val()) + 1);
                    }
                $(<%=NewNum.ClientID%>).val(number.val());
                $(<%=CartId.ClientID%>).val(id);
                $(<%=BtnUpdate.ClientID%>).click();
            });

            //去下单按钮
            $(".btnToOrder").click(function () {
                var cartId = $(this).prev().val();
                $(<%=CartId.ClientID%>).val(cartId);
                $(<%=BtnOrder.ClientID%>).click();
            })
            });
    </script>


</asp:Content>

